package com.sq.partner.manager.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PatternUtil {
	
	//验证身份证号码
	public static boolean idCardNumber(String number){
	    String rgx = "^\\d{15}|^\\d{17}([0-9]|X|x)$";
	    return isCorrect(rgx, number);
	  }
	
	//验证手机或者座机
	public static boolean telNumber(String number){
	    String rgx = "^(((0\\d{2,3})\\-)?(\\d{7,8})(\\-(\\d{3,}))?)|(1[358]\\d{9})$";
	    return isCorrect(rgx, number);
	  }
	
	//验证日期
	public static boolean dateNumber(String number){
	    String rgx = "^[12]\\d{3}[\\-\\/\\.]?((0[1-9])|1[0-2])([\\-\\/\\.]?(0[1-9]|[12][0-9]|3[01])(\\s?([01][0-9]|2[0-3])([\\-\\/\\.]?[0-5][0-9]([\\-\\/\\.]?[0-5][0-9])?)?)?)?$";
	    return isCorrect(rgx, number);
	  }
	
	//正则验证
	public static boolean isCorrect(String rgx, String res){
	    Pattern p = Pattern.compile(rgx);
	    Matcher m = p.matcher(res);
	    return m.matches();
	  }

}